package ah.com.ddh.endoce;

import sun.misc.BASE64Encoder;

public class Base64Test {

	public static void main(String[] args) {
		BASE64Encoder base64 = new BASE64Encoder();
		String c = Base64Test.toHex("".getBytes());
		String b = base64.encode("".getBytes());
		String bhex = Base64Test.toHex(b.getBytes());
	}
	
//	 将传递进来的字节数组转换成十六进制的字符串形式并返回
	private static String toHex(byte[] buffer) {

		StringBuffer sb = new StringBuffer(buffer.length * 2);

		for (int i = 0; i < buffer.length; i++) {

			sb.append(Character.forDigit((buffer[i] & 0xf0) >> 4, 16));

			sb.append(Character.forDigit(buffer[i] & 0x0f, 16));

		}

		return sb.toString();

	}
}
